﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WXYW.Entities;
using WXYW.DAL;

namespace WXYW.BLL
{
    public class ServiceStationService : RepositoryBase
    {
        public IQueryable<ServiceStation> GetALLServiceStations()
        {
            return GetEntities<ServiceStation>();
        }

        public ServiceStation GetServiceStation(int serviceStationID)
        {
            return GetEntities<ServiceStation>(p => p.ID == serviceStationID).FirstOrDefault();
        }

        public ServiceStation GetServiceStationByName(string stationName)
        {
            return GetEntities<ServiceStation>(p => p.Name.Equals(stationName)).FirstOrDefault();
        }

        public ServiceStation GetHeadServiceStation()
        {
            return GetEntities<ServiceStation>(p => p.Name.Equals("北京平台")).FirstOrDefault();
        }

        public void DeleteServiceStation(int serviceStationID)
        {
            DeleteEntity<ServiceStation>(s => s.ID == serviceStationID, Guid.Empty);
        }

        public void AddServiceStation(ServiceStation station)
        {
            InsertEntity(station);
        }

        public List<ServiceStation> GetAllWithSelectOne()
        {
            List<ServiceStation> serviceStationList = new List<ServiceStation>();
            ServiceStation selectOne = new ServiceStation();
            selectOne.ID = 0;
            selectOne.Name = "请选择平台";
            serviceStationList.Add(selectOne);
            serviceStationList.AddRange(GetEntities<ServiceStation>().ToList());
            return serviceStationList;
        }

        public void UpdateServiceStation(ServiceStation editStation)
        {
            UpdateEntity(editStation);
        }
    }
}
